package com.polly.esphwevent.common.utils;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @author liqin@nd.com.cn
 * @version V1.0
 * @title: EnvironmentUtil
 * @description: TODO(用一句话描述该文件做什么)
 * @date: 2019/2/27 16:40
 */

public class EnvironmentUtil {

    private static String hostName;

    /**
     * 获取主机名.
     */
    public static String getHostName() {
        if(null==hostName) {
            try {
                InetAddress netAddress = InetAddress.getLocalHost();
                return netAddress.getHostName();
            } catch (UnknownHostException e) {
            };
        }
        return hostName;
    }

}
